﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.ComponentModel;

namespace Kopain2
{

    /// <summary>This class is for handling the status bar of the application.
    /// </summary>
    class KopainStatusbar : INotifyPropertyChanged
    {

#region	Private properties.

        private string _filename;

        private static class PropertyName
        {
            public const string Filename = "Filename";
        }

#endregion	//	Private properties.

#region	Public properties.

        public string Filename
        {
            get { return _filename; }
            set
            {
                if (_filename != value)
                {
                    _filename = value;
                    Raise_PropertyChanged(PropertyName.Filename);
                }
            }
        }

#endregion	//	Public properties.

#region	Constructors.

        public KopainStatusbar()
        {
        }

#endregion	//	Constructors.

        public Binding CreateFilenameBinding()
        {
            Binding ret = new Binding();
            ret.Source = this;
            ret.Path = new PropertyPath(PropertyName.Filename);
            return ret;
        }

        private void Raise_PropertyChanged(string propertyname)
        {
            System.ComponentModel.PropertyChangedEventHandler temp = PropertyChanged;
            if (temp != null)
            {
                temp(this, new System.ComponentModel.PropertyChangedEventArgs(propertyname));
            }
        }

        #region INotifyPropertyChanged Members

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        #endregion

    }

}
